#ifndef __MODBUS_H
#define __MODBUS_H

#define MODBUS_PIN_TX
#define MODBUS_PIN_RX

#define MODBUS_NODE     0x48

#define MODBUS_TX_TIME  32
#define MODBUS_RX_SIZE  32

#include "stm8s.h"

typedef struct
{
  FunctionalState flag;
  uint8_t timer;
  uint8_t pc_data;
  uint8_t pc_node;
  uint8_t data_tx[16];
  uint8_t data[MODBUS_RX_SIZE];
  uint8_t node[8];
}type_modbus;

void modbus_init(void);
uint8_t* modbus_txpc(void);
void modbus_write(uint8_t* data, uint8_t len);
void modbus_err(uint8_t code, uint8_t err);
void modbus_fun(void);
void modbus_interrupt(void);
void modbus_timer(void);

#endif